package com.aidong.util;

import java.util.Map;

import net.sf.jxls.transformer.XLSTransformer;

import org.apache.log4j.Logger;

public class ExportUtil {
	private static Logger log = Logger.getLogger(ExportUtil.class);

	/**
	 * 根据模板生成XLS文件
	 * 
	 * @param filePath
	 * @param fileName
	 * @param templateFilePath
	 * @param templateFileName
	 * @param data
	 * @return
	 */
	public static boolean exportExcel(String filePath, String fileName, String templateFilePath,
			String templateFileName, Map<String, Object> data) {
		try {
			XLSTransformer transformer = new XLSTransformer();
			String createdFileName = filePath.concat(fileName);
			String templateFile = templateFilePath.concat(templateFileName);
			transformer.transformXLS(templateFile, data, createdFileName);
		} catch (Exception e) {
			log.error("Excel作成失败！", e);
			return false;
		}
		return true;
	}
}
